/*
 * // Bristleback plugin - Copyright (c) 2010 bristleback.googlecode.com
 * // ---------------------------------------------------------------------------
 * // This program is free software; you can redistribute it and/or modify it
 * // under the terms of the GNU Lesser General Public License as published by the
 * // Free Software Foundation; either version 3 of the License, or (at your
 * // option) any later version.
 * // This library is distributed in the hope that it will be useful,
 * // but without any warranty; without even the implied warranty of merchantability
 * // or fitness for a particular purpose.
 * // You should have received a copy of the GNU Lesser General Public License along
 * // with this program; if not, see <http://www.gnu.org/licenses/lgpl.html>.
 * // ---------------------------------------------------------------------------
 */

package pl.bristleback.server.bristle.binding;

import pl.bristleback.server.bristle.binding.resolvers.PropertyValueResolver;

/**
 * This annotation describes a single bound property in binding operation, is is element of {@link Bind} annotation.
 * It specifies name of property, method of extracting property value from token and additional validation information.
 * <p/>
 * Created on: 2011-01-27 17:55:48 <br/>
 *
 * @author Wojciech Niemiec
 */
public @interface Property {

  /**
   * Name of property to bind. Can be complex, like <code>nestedObject.listOfBeans.property1</code>.
   *
   * @return name of property.
   */
  String name();

  /**
   * Defines whether this property is required. If set to true and value of this property cannot be found,
   * binding error with type {@link pl.bristleback.server.bristle.binding.BindingErrorType#NOT_NULL_VIOLATION} is added.
   *
   * @return true if this property is required, false otherwise.
   */
  boolean required() default false;

  /**
   * Gets resolver of this property. If resolver is not specified by user,
   * default resolver will be chosen based on the type of property.
   *
   * @return property value resolver.
   * @see pl.bristleback.server.bristle.config.BristleConfiguration#getDefaultValueResolver(Class) 
   */
  Class<? extends PropertyValueResolver> valueResolver() default PropertyValueResolver.class;
}
